#ifndef _PARSE_TOKEN
#define _PARSE_TOKEN

#include "Buffer.h"
#include <string>

namespace parse_token {
	enum Parse_token {
		Par_sym,				// %%, partition symbol
		Code,					// 'code'
		Pattern,				// regular pattern
		Ucode_start,			// %{, user code definition starting symbol
		Ucode_end,				// %}, user definition code end symbol
		ID,						// identifier
		Item_start,				// the start of item code, ':{'
		Rig_big,				// }
		Lef_big,				// {
		End,					// the end
		RETURN_TYPE,			// return type token
		END_ACTION,				// end action label
		Undef					// undefined symbol
	};
	class Token {
	public:
		Token(mylib::Buffer &in) : in_str(&in) { token_type = parse_token::Undef; }
		Token(const std::string &str, Parse_token t) {
			in_str = 0;
			lexeme = str;
			token_type = t;
		}
		~Token() {}

		class Err_input {};		// exception
		Parse_token get();
		size_t len()const {return lexeme.size();}	// the length of current token
		const std::string &token()const {return lexeme;}	// the the token string
		Parse_token type()const{return token_type;}	// the token's type
	private:
		Token(const Token &token) {}		// cannot be copied
		Token &operator=(const Token &token) {}
	private :
		mylib::Buffer *in_str;	// the input stream
		std::string lexeme;
		Parse_token token_type;
	};
}
#endif
